﻿using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;
using System.Linq;
namespace HelperPrototype.Reports {
    
    public partial class DS_PhieuDanhGiaNCC {
        partial class PhieuDanhGiaNCCDataTable
        {
        }
    
        partial class HangHoaDataTable
        {
        }
    
        partial class Item_SupplierDataTable
        {
        }

        private string Ma = "";

        public void fillData(string ID)
        {
            this.Ma = ID;
            SqlConnection con = new SqlConnection(Properties.Settings.Default.myConnectionString);
            con.Open();

            string sql = "SELECT     H.TenHangHoa, C.TenNhaCungCap, D.ChatLuong, D.Gia, D.HauMai, D.ThoiGianGiaoHang, D.HinhThucThanhToan, D.Dat, D.GhiChu, N.MaNguoiTao,  N.MaNguoiDuyet" +
                        " FROM dbo.HangHoa H, dbo.NhaCungCap C, dbo.HangHoa_NhaCungCap D, dbo.PhieuDanhGiaNCC N" +
                        " WHERE H.MaHangHoa = D.MaHangHoa AND C.MaNhaCungCap = D.MaNhaCungCap AND N.MaPhieu = '" + ID + "' AND D.PhieuDanhGiaNCC_ID = N.MaPhieu";
            SqlDataAdapter dataAdaptor = new SqlDataAdapter(sql, con);
            dataAdaptor.Fill(this, "PhieuDanhGiaNCC");
            /*
            ID = SIR_ID;
            SqlConnection con = new SqlConnection(Properties.Settings.Default.myConnectionString);
            con.Open();

            string sql = "select ix.*, " +
                         "(select Item_Name from Item i where i.Item_ID = ix.Item_ID) Item_Name, " +
                         "(select Supplier_Name from Supplier s where s.Supplier_ID = ix.Supplier_ID) Supplier_Name " +
                         "from Item_Supplier ix " +
                         "where ix.SIR_ID = " + SIR_ID;
            SqlDataAdapter dataAdaptor = new SqlDataAdapter(sql, con);
            dataAdaptor.Fill(this, "Item_Supplier");*/
        }

        public void viewReport()
        {
            _DB.DataClasses1DataContext dc = new _DB.DataClasses1DataContext();
            _DB.PhieuDanhGiaNCC P = dc.PhieuDanhGiaNCCs.Single(s => s.MaPhieu == Ma);





            trash.CR_PhieuDanhGiaNCC report = new trash.CR_PhieuDanhGiaNCC();
            report.SetDataSource(this);
            report.SetParameterValue("MaPhieu", P.MaPhieu);
            //report.SetParameterValue("MaNguoiTao", P.NguoiTao.Ten);
            //report.SetParameterValue("NoiDung", P.NoiDung);
            ReportViewerForm form = new ReportViewerForm(report);
            form.ShowDialog();
            /*
            _DB.DataClasses1DataContext dc = new _DB.DataClasses1DataContext();
            _DB.SupplierInspectionReceipt sir = dc.SupplierInspectionReceipts.Single(s => s.SIR_ID == ID);

            CR_PhieuDanhGiaNCC report = new CR_PhieuDanhGiaNCC();
            report.SetDataSource(this);
            report.SetParameterValue("SIR_ID", ID);
            report.SetParameterValue("User_Name", sir.User.Name);
            report.SetParameterValue("Content", sir.Content);
            ReportViewerForm form = new ReportViewerForm(report);
            form.ShowDialog();*/
        }
    }
}

namespace HelperPrototype.DS_PhieuDanhGiaNCCTableAdapters {
    
    
    public partial class Item_SupplierTableAdapter {
    }
}
